﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.UnionPay
{
    /// <summary>
    /// 响应抽象
    /// </summary>
    [Serializable]
    public abstract class AResponse : AService
    {
        /// <summary>
        /// 实例化 AResponse
        /// </summary>
        protected AResponse()
        {

        }

        /// <summary>
        /// 签名键
        /// </summary>
        public static string sign_Key = "signature";

        protected IDictionary<string, string> UrlDic(string payParams)
        {
            string[] sw = payParams.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries);
            var dic = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
            foreach (string s in sw)
            {
                var index = s.IndexOf("=");
                if (index > 0)
                {
                    string key = s.Substring(0, index).Trim();
                    if (s.Length > index + 1)
                    {
                        string value = s.Substring(index + 1).Trim();
                        dic[key] = value;
                    }
                }
            }
            return dic;
        }

    }
}
